package com.hand.test02.controller;

import com.hand.test02.domain.Attach;
import com.hand.test02.domain.User;
import com.hand.test02.feign.AttachServiceFeign;
import com.hand.test02.service.IUserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 马旭阳
 * @date2019/7/26
 */
@RestController
public class UserController {
    @Autowired
    private IUserService userService;
    @Autowired
    private AttachServiceFeign attachServiceFeign;

    @GetMapping("/id")
    public User queryUserById(@RequestParam("id") Integer id){

        return userService.queryUserById(id);
    }
    @PostMapping("/user")
    public void insertUser(@RequestBody User user){

        userService.insertUser(user);
    }
    @PutMapping("/name")
    public void updateUser(@RequestBody User user){

        userService.updateUser(user);
    }
    @DeleteMapping("/userId")
    public void deleteUser(@RequestParam("id") Integer id){

        userService.deleteUser(id);
    }

    @PostMapping("/attach/byid")
    public Attach queryById(@RequestParam("id") Integer id){
        return attachServiceFeign.queryAttachById(id);
    }
    @PostMapping("/attach/aa")
    public void insertAttach(@RequestBody Attach attach){
         attachServiceFeign.insertAttach(attach);
    }
    @PutMapping("/attach/height/aa")
    public void updateAttach(@RequestBody Attach attach) {
       attachServiceFeign.updateAttach(attach);
    }
    @DeleteMapping("/attach/aId/aa")
    public void deleteAttach(@RequestParam("id") Integer id){
        attachServiceFeign.deleteAttach(id);
    }
}
